{include file="layout/header"}
{include file="layout/sidebar"}
<!-- 内容区域 -->
<div class="tpl-content-wrapper">
    <div class="container-fluid am-cf">
        <div class="row">
            <div class="am-u-sm-12 am-u-md-12 am-u-lg-9">
                <div class="page-header-heading"><span class="am-icon-clone page-header-heading-icon"></span> 文章管理 <small>Article manage</small></div>
                <p class="page-header-description">
                </p>
            </div>
            <div class="am-u-lg-3 tpl-index-settings-button">
                <button type="button" class="page-header-button"><span class="am-icon-paint-brush"></span> 设置</button>
            </div>
        </div>

    </div>
    <div class="row-content am-cf">

        <div class="row">
            <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
                <div class="widget am-cf">
                    <div class="widget-head am-cf">
                        <div class="widget-title  am-cf">文章列表</div>
                    </div>
                    <div class="widget-body  am-fr">

                        <div class="am-u-sm-12 am-u-md-6 am-u-lg-6">
                            <div class="am-form-group">
                                <div class="am-btn-toolbar">
                                    <div class="am-btn-group am-btn-group-xs">
                                        <button type="button" onclick="location='{:url('/form')}'" class="am-btn am-btn-default am-btn-success"><span class="am-icon-plus"></span>写博客</button><!-- 
                                        <button type="button" class="am-btn am-btn-default am-btn-secondary"><span class="am-icon-save"></span> 保存</button>
                                        <button type="button" class="am-btn am-btn-default am-btn-warning"><span class="am-icon-archive"></span> 审核</button>
                                        <button type="button" class="am-btn am-btn-default am-btn-danger"><span class="am-icon-trash-o"></span> 删除</button> -->
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="am-u-sm-12 am-u-md-6 am-u-lg-3">
                            <div class="am-form-group tpl-table-list-select">
                                <select data-am-selected="">
                                  <option value="">所有类别</option>
                                  {foreach name="category" item="vo"}
                                  <option value="{$vo.id}">{$vo.name}</option>
                                  {/foreach}
                                </select>
                            </div>
                        </div>
                        <div class="am-u-sm-12 am-u-md-12 am-u-lg-3">
                            <div class="am-input-group am-input-group-sm tpl-form-border-form cl-p">
                                <input type="text" class="am-form-field ">
                                <span class="am-input-group-btn">
                                        <button class="am-btn  am-btn-default am-btn-success tpl-table-list-field am-icon-search" type="button"></button>
                                </span>
                            </div>
                        </div>

                        <div class="am-u-sm-12">
                            <table width="100%" class="am-table am-table-compact am-table-striped tpl-table-black ">
                                <thead>
                                    <tr>
                                        <th>文章缩略图</th>
                                        <th>文章标题</th>
                                        <th>作者</th>
                                        <th>时间</th>
                                        <th>隐藏状态</th>
                                        <th>操作</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    {empty name="article_list"}
                                    <tr><td colspan="5" style="text-align: center;">还没有发布任何文章</td></tr>
                                    {else /}
                                    {foreach name="article_list" item="vo"}
                                    <tr>
                                        <td>
                                            <img src="{$vo.illustration}" class="tpl-table-line-img" alt="">
                                        </td>
                                        <td class="am-text-middle">{$vo.title}</td>
                                        <td class="am-text-middle">{$vo.author}</td>
                                        <td class="am-text-middle">{$vo.createtime |date="Y-m-d H:i:s",###}</td>
                                        <td class="am-text-middle">
                                            {eq name="vo.is_hide" value="1"}
                                                <button type="button" class="am-btn am-btn-warning am-round am-btn-sm is_hide" data-id="{$vo.id}">隐藏</button>
                                            {else /}
                                                <button type="button" class="am-btn am-btn-success am-round am-btn-sm is_hide" data-id="{$vo.id}">显示</button>
                                            {/eq}
                                            

                                        </td>
                                        <td class="am-text-middle">
                                            <div class="tpl-table-black-operation">
                                                <a href="{:url('/form/'.$vo.id)}">
                                                    <i class="am-icon-pencil"></i>修改
                                                </a>
                                                <a href="javascript:;" class="tpl-table-black-operation-del del" data-id="{$vo.id}">
                                                    <i class="am-icon-trash"></i> 删除
                                                </a>
                                            </div>
                                        </td>
                                    </tr>
                                    {/foreach}
                                    {/empty}
                                </tbody>
                            </table>
                        </div>
                        <div class="am-u-lg-12 am-cf">

                            <div class="am-fr">
                                <ul class="am-pagination tpl-pagination">
                                    <li class="am-disabled"><a href="#">«</a></li>
                                    <li class="am-active"><a href="#">1</a></li>
                                    <li><a href="#">2</a></li>
                                    <li><a href="#">3</a></li>
                                    <li><a href="#">4</a></li>
                                    <li><a href="#">5</a></li>
                                    <li><a href="#">»</a></li>
                                </ul>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    $('.is_hide').click(function(){
        var id = $(this).attr('data-id')
        $.ajax({    
            type:"post",
            url:"{:url('/admin/articles/is_hide')}",    
            data:{id:id},  
            success:function(data){ 
                if(data.status == 1){
                    location.reload();
                }  
            }    
        });
    });
    $('.del').click(function(){
        var id = $(this).attr('data-id');
        layer.confirm('确定删除文章吗？', {icon: 3, title:'提示'}, function(index){
            $.ajax({    
                type:"post",
                url:"{:url('/admin/articles/del')}",    
                data:{id:id},  
                success:function(data){ 
                    if(data.status == 1){
                        location.reload();
                    }  
                }    
            });
        });
    }); 
</script>
{include file="layout/footer"}